<template>
  <div class="new-box">
    <!-- <van-icon name="arrow-left" @click="goBack" /> -->
    <new-detail v-if="newId" @changflag="changflag"></new-detail>
    <news-vue v-else @changflag="changflag"></news-vue>
  </div>
</template>

<script>
import newsVue from "@/components/home/NewsView.vue";
import newDetail from "@/components/news/NewsView.vue";
export default {
  components: { newsVue, newDetail },
  data() {
    return {
      newId: false, // 控制显示新闻列表或者详情 开关
    };
  },
  methods: {
    // goBack() {
    //   this.changflag(false);
    //   if (JSON.stringify(this.$route.query) === "{}") {
    //     console.log(this.$route.query);
    //     this.$router.go(-1);
    //   }
    // },
    changflag(val) {
      this.newId = val;
    },
  },
  created() {
    this.newId = this.$route.query.id ? true : false;
  },
};
</script>

<style lang="scss" scoped>
.new-box {
  position: relative;
  i {
    padding-top: 20px;
    position: absolute;
    top: 00px;
    left: 0;
    background: #fff;
    display: block;
    height: 45px;
    line-height: 30px;
    width: 20px;
    z-index: 3;
  }

  .detail-head {
    background: #fff;
    padding-left: 10px;
    padding-right: 10px;
    height: 80px;
    line-height: 80px;
    font-weight: 800;
    font-size: 20px;
    text-align: center;
    position: -webkit-sticky;
    position: sticky;
    z-index: 1;
    top: 0px;
    i {
      color: #666;
      color: red;
      font-size: 28px;
      position: absolute;
      left: 0;
      top: 30px;
    }
  }
  ::v-deep .detail-content {
    margin-left: 20px;
    margin-right: 20px;
    h3 {
      font-size: 20px;
      height: 60px;
      line-height: 30px;
      text-align: center;
      margin-bottom: 20px;
    }
    div {
      p {
        font-size: 14px;
        line-height: 18px;
        text-indent: 2em;
        margin-bottom: 10px;
      }
      img {
        width: 100%;
        height: 100%;
        display: block;
      }
    }
  }
}
</style>
